//
//  SNReturnGoodsRepetitiousHeaderView.m
//  app
//
//  Created by 王少宁 on 15/5/21.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//  SNReturnGoodsRepetitiousTableView 的 headerView

#import "SNReturnGoodsRepetitiousHeaderView.h"
#import "SNReturnGoodsView.h"
#import "SNAddCommentsView.h"

@implementation SNReturnGoodsRepetitiousHeaderView

- (instancetype)initWithFrame:(CGRect)frame sn:(NSString *)sn createTime:(NSString *)createTime receiver:(NSString *)receiver isReturns:(NSString *)isReturns ostatus:(NSString *)ostatus goodsModel:(SNOrderFormDetailGoodsModel *)model
{
    if ([super initWithFrame:frame]) {
        SNReturnGoodsView * snBasicView = [[SNReturnGoodsView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, frame.size.height-114) sn:sn createTime:createTime receiver:receiver isReturns:isReturns ostatus:ostatus];
        [self addSubview:snBasicView];
        
        SNAddCommentsView * goodsView = [[SNAddCommentsView alloc] initWithFrame:CGRectMake(0, snBasicView.ufo.yy, SCREEN_WIDTH, 114) model:model type:GoodsViewTypeReturnGoods];
        [self addSubview:goodsView];
        
        UIButton * nextServeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        nextServeBtn.frame = CGRectOf([goodsView.ufo fx:1.0 ox:-100 fy:1.0 oy:-35],
                                      [goodsView.ubo uw:-24 ow:100 oh:30]);
        nextServeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3, 0, 0);
        nextServeBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [nextServeBtn setTitle:@"继续售后" forState:UIControlStateNormal];
        [nextServeBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
        [nextServeBtn addTarget:self action:@selector(nextServeBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:nextServeBtn];
        
        UIImageView * rightArrowImgView = CREATE_WITH_FRAME_OF(UIImageView, [nextServeBtn.ubo fx:1.0 ox:-8 fy:0 oy:8.25],
                                                               [nextServeBtn.ubo ow:8 oh:13.5]);
        rightArrowImgView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow_right_orange@2x" ofType:@"png"]];
        [nextServeBtn addSubview:rightArrowImgView];
    }
    return self;
}

+ (instancetype)viewWithFrame:(CGRect)frame sn:(NSString *)sn createTime:(NSString *)createTime receiver:(NSString *)receiver isReturns:(NSString *)isReturns ostatus:(NSString *)ostatus goodsModel:(SNOrderFormDetailGoodsModel *)model
{
    return [[self alloc] initWithFrame:frame sn:sn createTime:createTime receiver:receiver isReturns:isReturns ostatus:ostatus goodsModel:model];
}

- (void)nextServeBtnClick
{
    if ([self.deletage respondsToSelector:@selector(nextServeBtnInHeaderViewClick)]) {
        [self.deletage performSelector:@selector(nextServeBtnInHeaderViewClick)];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
